<extend name="Public/base"/>
<block name="style">
	<style type="text/css">
	 .verifyimg{
	 	padding: 0;
	 	height: 70px;
	 	height: 7rem;
	 }
	 .reloadverify,.reloadverify:hover,.reloadverify:focus{
	 	color: #69c3ff;
	 	text-decoration: none;
	 }
	</style>
</block>
<block name="page-header">
	<li><a href="U('User/index')"><i class="fa fa-table"></i>{$meta_title}</a></li>
	<li class="active"><i class="fa fa-user"></i>权限管理</li>
</block>
<block name="body">
<div class="row">
	<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
		<div class="tabs">
			<ul class="nav nav-tabs">
				<li class="active">
					<a href="#add" data-toggle="tab">添加用户</a>
				</li>
				<li>
					<a href="#delete" data-toggle="tab">注销用户</a>
				</li>
				<li>
					<a href="#auth" data-toggle="tab">权限管理</a>
				</li>
			</ul>
			<div class="tab-content">
				<div id="add" class="tab-pane active">
					<form action="{:U('User/adduser')}" method="post">
						<div class="form-group">
							<div class="row">
								<div class="col-sm-6">
							<label for="nf-user">用户名：</label>
							<input type="text" id="nf-user" name="username" class="form-control" autocomplete="off" placeholder="请输入用户名">
								</div>
								<div class="col-sm-6">
									<select name="select" id="select">
										<option value="1">超级管理员</option>
										<option value="2">管理员</option>
										<option value="3">普通用户</option>
									</select>
								</div>
							</div>
						</div>
						<div class="form-group">
							<div class="row">
								<div class="col-sm-6">
								<label for="nf-password">密 码：</label>
								<input type="password" id="nf-password" name="password" class="form-control" placeholder="请输入密码">
								</div>
								<div class="col-sm-6">
								<label for="nf-repassword">确认密码：</label>
								<input type="password" id="nf-repassword" name="repassword" class="form-control" placeholder="请输入确认密码">
								</div>
							</div>
						</div>
						<div class="form-group">
							<label for="nf-email">邮 箱：</label>
							<input type="text" id="nf-email" name="email" class="form-control" placeholder="请输入邮箱">
						</div>
						<div class="form-group">
							<div class="row">
								<div class="col-sm-6">
							<label for="nf-verify">验证码：</label>
							<input type="text" id="nf-verify" name="verify" class="form-control" autocomplete="off" placeholder="请输入验证码"><a class="reloadverify" title="换一张" href="javascript:void(0)">看不清？换一张</a>
								</div>
								<div class="col-sm-6">
								<img class="reloadverify verifyimg form-control" src="{:U('Public/verify')}">
								</div>
							</div>
							<div class="check-tips"></div>
						</div>
						<div class="form-group">
							<button type="submit" class="btn btn-success btn-lg">确 定</button>
						</div>
					</form>
				</div>
				<div id="delete" class="tab-pane">
					<form action="{:U('User/submitpass')}" method="post">
						<div class="form-group">
							<label for="nf-old">原密码：</label>
							<input type="password" id="nf-old" name="old" class="form-control" placeholder="原密码">
							<span class="help-block">请输入原密码</span>
						</div>
						<div class="form-group">
							<label for="nf-password">新密码：</label>
							<input type="password" id="nf-password" name="password" class="form-control" placeholder="新密码">
							<span class="help-block">请输入新密码</span>
						</div>
						<div class="form-group">
							<label for="nf-repassword">确认密码：</label>
							<input type="password" id="nf-repassword" name="repassword" class="form-control" placeholder="确认密码">
							<span class="help-block">请输入确认密码</span>
						</div>
						<div class="form-group">
							<button type="submit" class="btn btn-success btn-lg">确 定</button>
						</div>
					</form>
				</div>
				<div id="auth" class="tab-pane">
					<form action="{:U('User/submitpass')}" method="post">
						<div class="form-group">
							<label for="nf-old">原密码：</label>
							<input type="password" id="nf-old" name="old" class="form-control" placeholder="原密码">
							<span class="help-block">请输入原密码</span>
						</div>
						<div class="form-group">
							<label for="nf-password">新密码：</label>
							<input type="password" id="nf-password" name="password" class="form-control" placeholder="新密码">
							<span class="help-block">请输入新密码</span>
						</div>
						<div class="form-group">
							<label for="nf-repassword">确认密码：</label>
							<input type="password" id="nf-repassword" name="repassword" class="form-control" placeholder="确认密码">
							<span class="help-block">请输入确认密码</span>
						</div>
						<div class="form-group">
							<button type="submit" class="btn btn-success btn-lg">确 定</button>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>
</block>
<block name="script">
	<script type="text/javascript">
	$("form").submit(function(){
		var self = $(this);
		$.post(self.attr("action"), self.serialize(), success, "json");
		return false;
		function success(data) {
			if (data.status==1){
				updateAlert(data.info, 'alert-success');
				setTimeout(function(){
					location.reload();
				},1000);
			}else{
				self.find(".check-tips").text(data.info);
				$("#nf-verify").val("").focus();
				$(".reloadverify").click();
			}
		}
	});
	$(function(){
		var verifyimg = $(".verifyimg").attr("src");
		$(".reloadverify").click(function(){
			if (verifyimg.indexOf('?') > 0) {
				$(".verifyimg").attr("src", verifyimg+'&random='+Math.random());
			}else{
				$(".verifyimg").attr("src", verifyimg.replace(/\?.*$/, '')+'?'+Math.random());
			}
		});
	});
	</script>
</block>
